﻿@model RTW.Models.TCategory
@{
    ViewData["Title"] = "CategoryInfoEdit";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@section head{
    <link href="/css/bootstrap.min.css?v=3.3.6" rel="stylesheet" />
    <link href="/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" />
    <link href="/css/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet" />
    <link href="/css/animate.min.css" rel="stylesheet" />
    <link href="/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" />
    <link href="/css/plugins/iCheck/custom.css" rel="stylesheet" />
    <link href="/css/style.min.css?v=4.1.0" rel="stylesheet" />
    <style type="text/css">
        .input-group-addon {
            width: 150px;
        }

        .input-group {
            margin-bottom: 15px;
            text-align: center;
            width: 100%;
        }

        .text-left label {
            font-weight: normal;
            margin-right: 8px;
            margin-left: 2px;
        }

        .checkbox label, .radio label {
            padding-left: 0px;
        }

    </style>

}

<form id="form1" asp-action="CategoryInfoEdit">
    <div id="dContent">
        <div class="input-group">
            <span class="input-group-addon">门类名称</span>
            @Html.TextBoxFor(m => m.CName, new { @class = "form-control", dataType = "null", Msg = "账号不能为空!" })
        </div>
        <div class="input-group">
            <span class="input-group-addon">门类类型</span>
            @Html.DropDownListFor(m => m.CType, new SelectList(
                                                  new List<object>{
                                                       new { value = 1 , text = "文件夹" },
                                                       new { value = 2 , text = "案卷" } ,
                                                       new { value = 3 , text = "案卷含卷内" },
                                                       new { value = 4 , text = "图片" }
                                                    },
                                                  "value",
                                                  "text"
                                                ), new { @class = "form-control" })
        </div>
        <div class="input-group">
            <span class="input-group-addon">上级门类</span>
            @Html.DropDownListFor(m => m.ParentID, ViewBag.Categorys as IEnumerable<SelectListItem>, new { @class = "form-control", dataType = "null", Msg = "请选择身份!" })
        </div>
        <div class="input-group">
            <span class="input-group-addon">数据库表名</span>
            @Html.TextBoxFor(m => m.DBTable, new { @class = "form-control" })
        </div>
        <div class="input-group">
            <span class="input-group-addon">档号编制公式</span>
            @Html.TextBoxFor(m => m.DHformula, new { @class = "form-control" })
        </div>
        <div class="input-group">
            <span class="input-group-addon">系统门类</span>
            <div class="form-control text-left">
                <div class="checkbox i-checks" style="float: left; margin-right: 5px; width: 150px; text-align: left; margin-top: 5px;">
                    @Html.CheckBoxFor(m => m.IsSys)
                    <label style="padding-left: 0px;">
                        系统门类
                    </label>
                </div>
            </div>
        </div>
        <div class="input-group">
            <span class="input-group-addon">备注</span>
            @Html.TextAreaFor(m => m.Remarks, new { @class = "form-control", TextMode = "MultiLine", Height = "95" })
        </div>
    </div>
    <div class="zui-footer">
        <button id="btnSave" class="btn btn-primary btn-sm" type="submit">保存</button>

        <button class="btn btn-default btn-sm" type="button" onclick="closePage()">关闭</button>
    </div>

    @Html.HiddenFor(m => m.DMID)
    @Html.HiddenFor(m => m.ID)
</form>

@section scripts{
    <script src="~/js/jquery.min.js?v=2.1.4"></script>
    <script src="~/js/bootstrap.min.js?v=3.3.6"></script>
    <script src="~/lib/jquery.form/jquery.form.min.js"></script>
    <script src="~/js/plugins/validate/jquery.validate.min.js"></script>
    <script src="~/js/My97DatePicker/WdatePicker.js"></script>
    <script src="~/js/plugins/layer/layer.min.js"></script>
    <script src="~/js/plugins/iCheck/icheck.min.js"></script>
    <script src="~/js/verification.js"></script>
    <script src="~/js/zuiCode.js"></script>
    <script type="text/javascript">
        //提交
        (function ($) {
            $.info = {
                init: function () {
                    $(".i-checks").iCheck({
                        checkboxClass: "icheckbox_square-green",
                        radioClass: "iradio_square-green"
                    })
                },
                formSubmit: function () {
                    $("#form1").validate({
                        rules: {
                            UserAccount: {
                                required: true
                            },
                            UserName: {
                                required: true
                            },
                            RoleID: {
                                required: true
                            }
                        },
                        errorPlacement: function (error, element) {
                            //错误消息不为空，提示Msg消息或默认消息
                            if (error[0].textContent != "") {
                                if (error[0].textContent != undefined) {
                                    let msg = element.attr("Msg") ? element.attr("Msg") : error.textContent;
                                    showTip(msg, 2);
                                }
                            }
                        },
                        onkeyup: false,
                        focusCleanup: true,
                        success: "valid",

                        submitHandler: function (form) {
                            //return verfic('tip', '#dContent');
                            //var fRankName = $("select[name='fRankId']").find("option:selected").text();
                            //var fState = $("input[name='fState']").is(':checked');
                            $(form).ajaxSubmit({
                                type: "POST",
                                cache: false,
                                //data: { fRankName: fRankName, fState: fState },
                                dataType: "json",
                                error: function (XMLHttpRequest, textStatus, errorThrown) {
                                    if (XMLHttpRequest.status != 200) {
                                        showTip(errorThrown, 2);
                                    }
                                },
                                success: function (result) {

                                    var state = result.success;
                                    var message = result.msg;
                                    if (state) {
                                        showTip(message, 1, 2);
                                    } else {
                                        showTip(message, 2);
                                    }

                                }
                            });
                        }
                    });
                }
            };
            $(function () {
                $.info.init();
                $.info.formSubmit();
            });
        })(jQuery);
    </script>
}
